﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace F1_OrderController
{
    public partial class Form2 : Form
    {
        int row = 0;
        BindingSource orderBindingSource = new BindingSource();
        public Form2(int row)
        {
            InitializeComponent();
            this.row = row;
            orderBindingSource.DataSource = Orders.orderService.orderList[row].orderDetails;
            orderListDGV.DataSource = orderBindingSource;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                Orders.orderService.orderList[row].orderDetails.id = Convert.ToInt32(textBox1.Text);
                Orders.orderService.orderList[row].orderDetails.Goods = textBox2.Text;
                Orders.orderService.orderList[row].orderDetails.Money = Convert.ToDouble(textBox3.Text);
                Orders.orderService.orderList[row].orderDetails.Customer = new e1.Customers(textBox4.Text);
                Orders.orderService.orderList[row].orderDetails.customer = textBox4.Text;
            }
            catch(Exception exception)
            {
                MessageBoxButtons messButton = MessageBoxButtons.OKCancel;
                DialogResult dr = MessageBox.Show(exception.Message, "提示", messButton);
            }
            this.Close();
        }
    }
}
